<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.css" rel="stylesheet" />
		<link href="../../css/list.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		 <script src="../../js/app.js"></script>
		 <script src="../../js/common.js"></script>
		 <link href="../../css/style.css" rel="stylesheet" />
		 <!--<link href="../css/icons-extra.css" rel="stylesheet"/>-->
		 <link rel="stylesheet" href="../../font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="../css/detail.css" type="text/css" />
		 		<style type="text/css">
		.speak{
			/*输入框居中漂浮*/
		position: fixed;
		width:100%;
		top:30%;
		/*left:50%;*/
		margin: auto auto;
		padding: 0 5px;
		text-align: center;
				 			}
		.mui-content-padded{
			/*padding: auto 5px;*/
		}
		 		</style>
</head>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  <h1 class="mui-title"><span id="title">项目概况</span></h1><p id="titleright" style="float: right;font-size: 0.6em;">举报</p>
</header>

    <div class="mui-content">
    	<div id="head" style="padding: 2px 10px;"></div>
    	<!--海报-->
    <div  style="width:100%;text-align:center" id="image"></div>
    <div id="neirong" class="mui-content-padded"></div>
    <!--<div id="below" class="mui-content-padded"></div>-->
    <li class="mui-content-padded" style="border-bottom:solid 1px #E3E3E3;"><span>创作团队</span></li>
    <div class="slide-box" id="resume"></div>
    <li class="mui-content-padded" style="border-bottom:solid 1px #E3E3E3;"><span>相关新闻</span></li>
    <div class="slide-box" id="news"></div>
    <!--出品公司-->
      <!--项目概况表格-->
    <div id="table" class="mui-content-padded"></div>
      <!--来源-->
    <li class="mui-content-padded"id="foot"><span>发布人</span></li>
    <li class="mui-content-padded"style="border-bottom: 1px solid #E3E3E3;">主题评论：</li>
		<div class="mui-content-padded" id="comment">
			 <!--评论信息-->
		</div>
    </div>
    <!--评论窗口-->
    <div  id="fabiao" style="display:block;position:fixed;right:30px;bottom:60px;background: #DD524D;color:#fff;border-radius:10px;padding: 5px;" >发表评论
</div>
<div id="speak" class="speak" style="display:none;background: #DDDDDD;">
	<p style="margin:auto auto;font-size: 1.2em;color:#EC971F">发表评论</p>
	<textarea id="content" type="text" placeholder="留言"></textarea>
	<div style="margin-top: -24px;border-radius:5px;">
	<input id="pubish" style="font-size: 18px;margin: 2px 5px;padding:0 10px;float: right;" value="确认" type="submit" onclick="javascript:(document.getElementById('fabiao').style.display='block')">
	<input  style="font-size: 18px;margin: 2px 5px;float: right;padding:0 10px;" value="取消" type="submit" onclick="javascript:(document.getElementById('speak').style.display='none');javascript:(document.getElementById('fabiao').style.display='block')">
	</div>
</div>
<script type="text/javascript">
//	var tid=localStorage.itemdetailid;
var btn = document.getElementById("fabiao");
//监听点击事件
btn.addEventListener("tap",function () {
	 speak('',tid,'item');
//	alert(tid);
  console.log("tap event trigger"+tid);
});
//主图大图
function imageplay(image,tid){
	document.getElementById('image').innerHTML='<img  style="width:95%;" src="'+home.uploads+'/img/item/'+image+'" onerror="this.onerror=null;this.src=\'../../images/iconfont-tianjia.png\'" />';
}
//获取关联信息主创团队
 function getrelation(tid,mod){
	apptoken['relation']=mod||'';
	apptoken['tid']=tid ||'';
	apptoken['act']='team';
	 mui.post(home.hos+'/item?tid='+tid,apptoken,function(data){
if(isJSON(data)){
//      			alert(data);
result=JSON.parse(data);//获取信息
var val1='';
var val2='';
var val3='';
var val4='';
for(var i=0;i<result.length;i++){
		if(result[i].confirm=='1'){
			confirm='拟约';
		}else{
			confirm='已定';
		}
	if('undefined'==result[i]['image']){
			pics=''
		}else{
			pics='<div class="con" ><div class="pic" style="max-width:100px;min-height:10px;padding:2px;position:relative" ><p style="position:absolute;text-align:center;border-radius:9px;color:#fff;line-height:1em;background:red;padding:3px">'+confirm+'</p><img  src="'+home.uploads+'/img/item/team/min'+result[i]['image']+'" onclick="goto(\'item\',\'home\',\'team_detail\','+result[i].id+')" /><h5>'+result[i]['duty']+'</h5> <p>'+result[i]['name']+'</p></div></div>';
//			alert(home.uploads+'/img/item/team/'+result[i]['image']);
	};
	if(result[i]['class']=='1'){
		val1+=pics;
	}else if(result[i]['class']=='2'){
		val2+=pics;
	}else if(result[i]['class']=='3'){
		val3+='<div class="con" ><div class="pic"  style="max-width:100px;min-height:10px;padding:2px;position:relative" ><p style="position:absolute;text-align:center;border-radius:9px;color:#fff;line-height:1em;background:red;padding:3px">'+confirm+'</p><img  src="'+home.uploads+'/img/item/team/min'+result[i]['image']+'" onclick="goto(\'item\',\'home\',\'team_detail\','+result[i].id+')" /><h5>饰:'+result[i]['duty']+'</h5> <p>'+result[i]['name']+'</p></div></div>';
	}else if(result[i]['class']=='4'){
		val4+=pics;
	}
}
//创作团队
document.getElementById('resume').innerHTML='<div class="con"><div class="pic" style="width:1.5em;">主创团队</div></div>'+val1+'<div class="con"><div class="pic" style="width:1.5em;">技术团队</div></div>'+val2+'<div class="con"><div class="pic" style="width:1.5em;">演员</div></div>'+val3+'<div class="con"><div class="pic" style="width:1.5em;">合作机构</div></div>'+val4;

//相关新闻
//document.getElementById('performer').innerHTML='<div id="con"><div class="pic" style="width:1.5em;">拟定</div></div>'+val3;
}
},'text');
}
 var	p= 0;
 //获取相关新闻信息
 function getnews(tid,mod,num){
 	if(num==1){p=p+1}else{p=0;};
 	apptoken['p']= p;
	apptoken['relation']=mod||'';
	apptoken['tid']=tid ||'';
	apptoken['act']='relationlist';
	 mui.post(home.hos+'/news?p='+p+'&'+'tid='+tid+'&'+'rel=item',apptoken,function(data){
//	 	alert(data)
if(isJSON(data)){
		result=JSON.parse(data);//获取信息
var val1='';
var val2='';
var val3='';
var val4='';
for(var i=0;i<result.length;i++){

result[i]['image']=result[i]['img'];
	if('undefined'==result[i]['image']){
			pics=''
	}else{
			pics='<div id="'+result[i]['image']+'" class="con"style="" onclick="goto(\'news\',\'home\',\'detail\','+result[i].id+')"><div class="pic" style="max-width:100px;min-height:10px;padding:2px;max-height:280px;position:relative" ><img  src="'+home.uploads+'/img/news/'+result[i]['image']+'" /> <p style="font-size:0.5em">'+result[i]['content']+'</p></div></div>';

	};
	result[i]['class']=result[i]['zan'];
if(result[i]['class']=='1'){
		val1+=pics;
	}else if(result[i]['class']=='2'){
		val2+=pics;
	}else if(result[i]['class']=='3'){
		val3+=pics;
	}else if(result[i]['class']){
		val4+=pics;
	}
}
//相关新闻
document.getElementById('news').innerHTML='<div class="con"><div class="pic" style="width:1.5em;">新闻动态</div></div>'+val4+'<div class="con"><div class="pic" ></div></div>';
}
},'text');
}
 
 function addorders(tid,title,money,share,repaytime,synopsis,user_id){
 	var jsarr={};
// 	alert(user_id+'uid'+tid+title+money+share);
   	jsarr['tid']=tid;
   	jsarr['title']=title;
   	jsarr['money']=money;
   	jsarr['share']=share;
   	jsarr['repaytime']=repaytime;
   	jsarr['synopsis']=synopsis;
   	jsarr['user_ida']=user_id;
   	localStorage.itembuy=JSON.stringify(jsarr);
 	mui.openWindow('../admin/orders_publish.html');
 }
 //获取详情
function jsonarrfor(result){
	//获取主创团队
	getrelation(result.id,'team');
	//获取相关新闻信息
	getnews(result.id,'news',0);
	//获取评论信息
	list_comment(tid,'item',0);

var classimg='';
var vals='';
var str=JSON.stringify(result);
var rugu='<span onclick="addorders('+result.id+',\''+result.title+'\','+result.moneyunit+','+(result.share-result.sharenow)+','+result.repaytime+',\''+result.synopsis+'\','+result.user_id+')" >我要入股</span>'; //
if(result.share-result.sharenow<=0){//判断是否有剩余股份
	rugu='股份已认领完毕';
}

//if(result.status==1){
	casestate='<span onclick="goto(\'chat\',\'user\',\'detail\','+result.user_id+')"style="border-radius:25px;border:2px solid #a1a1a1;padding:5px 5px">聊聊<i class="mui-icon mui-icon-chatbubble"></i></span>';
//}else{
//	casestate='<span style="color:red;">■</span><span style="border-radius:25px;border:2px solid #a1a1a1;padding:2px 5px">'+result.stage+'</span>';
//}
//完成进度
var Completion=Math.round(result.sharenow/result.share*10000)/100;
//发布日期
var createtime=new Date(parseInt(result.createtime) * 1000).format('yyyy年M月d日');
val='<div style="text-align:center"><h3>'+result.classname+':'+result.title+'</h3><p  style="background: transparent;">运行阶段:<span style="color:red">'+result.stage+'</span></p><p>'+casestate+'</p><h4>简介</h4><p><span id="synopsis">'+result.synopsis+'</span></p></div>';
//形象头像
if(result.poster && result.poster.length>6){
imageplay(result.poster,result.id);	
}
//附件是否存在
if(result.filename){
		var download='<button type="button" class="mui-btn mui-btn-outlined mui-btn-danger" onclick="download('+result.id+',\''+result.title+'\')">获取策划案</button>';

}else{
	var download='<button type="button" class="mui-btn mui-btn-outlined mui-btn-danger" >未上传附件</button>';
}
var title='<h1 class="mui-title">项目概况<span>【'+result.stage+'】</span></h1>';
//判断筹备进度达到100%屏蔽表格
if(Completion<100){
	var table='<li style="border-bottom:solid 1px #E3E3E3;"><span id="situation">项目概况</span></li><div class="list-head" ><table><tr><td width="110px">项目名称</td><td>'+result.title+'</td></tr><tr><td width="110px">项目类型</td><td>'+result.classname+'</td></tr><tr><td width="110px">出品公司</td><td>'+result.classname+'</td></tr><tr><td width="110px">项目负责人</td><td>'+result.head+'</td></tr><tr><td width="110px">支持入股方式</td><td>'+result.source+'</td></tr><tr><td width="110px">接受资源类别</td><td>'+result.resources+'</td></tr><tr><td width="110px">接受技术类别</td><td>'+result.technology+'</td></tr><tr><td>预计回报日期</td><td>'+result.repaytime+'日</td></tr><tr><td>拆分股份数</td><td>'+result.share+'股/份</td></tr><tr><td>每份估价</td><td>'+result.moneyunit+'元</td></tr><tr><td>预估总值约</td><td>'+(result.share*result.moneyunit/10000)+'万</td></tr><tr><td>已被认领</td><td>'+result.sharenow+'股</td></tr><tr><td>剩余数量</td><td>'+(result.share-result.sharenow)+'股</td></tr><tr><td colspan="2"style="text-align:center;background:#FFF;overflow:hidden">筹备进度:'+Completion+'%<div class="btn-right"style="text-align:center;width:100%;background:#B7B7B7;padding:1px 0;"><span class="btn-left"style="padding:2px 0;width:'+Completion+'%;background:#66CDAA;"></span></div><br>当前处于【'+result.stage+'】阶段</td></tr><tr><td  colspan="2" style="text-align:center;color:#fff;" id="download"><button type="button" class="mui-btn mui-btn-outlined mui-btn-danger" >'+rugu+'</button>'+download+'</td></tr></table></div>';
}else{
	var table='<li style="border-bottom:solid 1px #333;"><span id="situation">新闻动态</span></li>';
}
var collecttitle=result.classname+':'+result.title;
document.getElementById('table').innerHTML=table;
document.getElementById('neirong').innerHTML=val;
var below='<div style="width:100%;height:35px;font-size:0.8em;border-bottom: 1px solid #E3E3E3;text-align:center;"><div style="width: 33%;float:left"onclick="speak()">评论：<span id="commentnum">'+result.comment+'</span></div><div style="width: 33%; float:left"onclick="zan('+result.id+',\'\',\'item\')"><i class="fa fa-thumbs-o-up fa-1x"></i>：<span id="zannum">'+result.zan+'</span></div><div style="width: 33%;float:left"onclick="addcollect('+result.id+',\'item\',\''+collecttitle+'\')">收藏：<span id="collectnum'+result.id+'">'+result.collect+'</span></div></div>'

document.getElementById('head').innerHTML='<div style="font-size:0.8em;"><span  style="" onclick="goto(\'chat\',\'home\',\'detail\','+result.user_id+')">发布人：'+result.username+'</span><span style="margin-left:20px;font-size:0.6em">发布于：'+createtime+'</span></div>';
document.getElementById('foot').innerHTML=below;
document.getElementById('titleright').innerHTML='<div id="report" style="margin-top:10px;float:right">'+result.report+'</div><div style="float:right"><select style="padding:10px;background-color:transparent;" onchange="report('+result.id+',\'item\',this)"><option>投诉</option><option>色情</option><option>侵权</option><option>脏话</option><option>诽谤</option><option>低俗</option><option>虚假</option><option>其他</option></select></div>';
}

function download(tid,title){
	 mui.prompt('请输入授权码', '密码','' , ['取消','确认'], function(e) {
        if (e.index == 1) {
host=home.hos+'/item/download';
jsondata='{"tid":"'+tid+'","name":"'+title+'","ps":"'+e.value+'"}';
createDownload(host,jsondata);
        }else{
        	alert('您选择了取消');
        }
    },'div')
//	alert('下载');
}


// 创建下载任务
function createDownload(host,jsondata) {
var w=plus.nativeUI.showWaiting("　　 开始下载...　　 ");
	var dtask = plus.downloader.createDownload(host,{filename:"_doc/",method:"POST",data:jsondata,timeout:60,retry:2,retryInterval:2}, function ( d, status ) {
		// 下载完成
		if ( status == 200 ) { 
			var btnArray = ['否', '是']; //弹框消息确认是否打开附件 
mui.confirm('是否打开附件查看？', '下载成功', btnArray, function(e) { 
if(e.index == 1) { //打开附件 
	plus.runtime.openFile(d.filename, {}, function(e) { //调用第三方应用打开文件 
	plus.runtime.launchApplication({ 
		pname: "com.chaozh.iReaderFree"
		}, function(e) { 
					plus.nativeUI.confirm('检查到您未安装文件查看器','是否需要下载安装？', function(i) { 
							if(i.index == 0) { 
							document.location.href = PDFAPPUrl 
							return; 
							} 
					}); 
			})
	}); 
} else { //不打开
                }
            })
        } else {
            plus.nativeUI.alert("文件不存在或者下载失败：" + status);
        }
   });
     dtask.addEventListener( "statechanged", function(task,status){
                        switch(task.state) {
                            case 1: // 开始
                                w.setTitle("　　 开始下载...　　 ");
                            break;
                            case 2: // 已连接到服务器
                                w.setTitle("　　 开始下载...　　 ");
                            break;
                            case 3:
                                var a = task.downloadedSize/task.totalSize*100;
                                w.setTitle("　　 已下载"+parseInt(a)+"%　　 ");
                            break;
                            case 4: // 下载完成
                                w.close();
                            break;
                        }
                  } );
                   dtask.start();
}

apptoken['tid']=tid;//获取主题详情id
apptoken['act']='detail';
mui.post(home.hos+'/item?tid='+apptoken['tid'],apptoken,function(data){
//	alert(data);
	if(isJSON(data)){
//      			alert(data);
		result=JSON.parse(data);//获取信息
		jsonarrfor(result);//加载详情信息
//		_relation(result.relation,result.relation_id);//加载关联信息
//		list_comment(result.id);//加载评论信息
		}else{
			alert(apptoken['tid']+'页面加载失败，或不存在，请重新尝试');
			return false;
    	}
})

//function goto(module,room,htmlname,this_id){//我的微博
//	localStorage[module+room+htmlname+'id']=this_id;
//	mui.openWindow('../../'+module+'/'+room+'/'+htmlname+'.html');
//	}
  </script>